<?php

/**
 * This file is part of the Framework03 PHP framework.
 * @author Walter Tamboer
 * @package Framework03
 */

class FW_Uri
{
    public static function factory($uri)
    {
        $uri = explode(':', $uri, 2);
        $scheme = strtolower($uri[0]);
        $urn = isset($uri[1]) ? $uri[1] : '';

        switch ($scheme)
        {
        case 'http':
            return new FW_Uri_Http($urn);

        case 'https':
            return new FW_Uri_Https($urn);

        case 'ftp':
            return new FW_Uri_Ftp($urn);

        case 'ftps':
            return new FW_Uri_Ftps($urn);

        case 'mailto':
            return new FW_Uri_Mailto($urn);

        default:
            throw new FW_Uri_Exception('Scheme "'.$scheme.'" is not supported');
        }

        return null;
    }
}
